# backend/schemas/node.py
from datetime import datetime
from uuid import UUID
from pydantic import BaseModel


class NodeBase(BaseModel):
    name: str
    host: str
    port: int
    protocol: str | None = None
    location: str | None = None
    is_active: bool = True
    load_percent: int | None = None


class NodeCreate(NodeBase):
    pass


class NodeUpdate(NodeBase):
    name: str | None = None
    host: str | None = None
    port: int | None = None
    is_active: bool | None = None


class NodeOut(NodeBase):
    id: UUID
    created_at: datetime

    class Config:
        from_attributes = True  # 替代 orm_mode